<?php
  if(isset($_POST['button'])){
      switch($_POST['color']){
          case '1':
            $color='#FF0000';
            break;
          case '2':
            $color='#009900';
            break;
          case '3':
            $color='#0000FF';
            break;
          default:
            $color='#000000';
      }
      echo <<< str
      <script>
        window.onload=function(){
        document.getElementById('p').style.color='$color'
       }
      </script>
      str;
  }
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="" method="POST">
       <p id='p'>改变我的颜色</p>
       <select name="color" id="">
       <option value="0">请选择颜色</option>
       <option value="1">红色</option>
       <option value="2">绿色</option>
       <option value="3">蓝色</option>
       </select>
       <input type="submit" name="button" value="改变颜色">
    </form>
</body>
</html>